<template>
  <view class="container">
    <uni-nav-bar
      left-icon="left"
      title="管理员注册"
      @clickLeft="D.back()"
      background-color="#007AFF"
      dark
    ></uni-nav-bar>
    <uni-forms
      :rules="D.rules"
      :model="D.currentModel"
      class="vcbox"
      ref="formRef"
    >
      <uni-forms-item label="学校" name="schoolId" required>
        <uni-data-select
          v-model="D.currentModel.schoolId"
          :localdata="D.schools.value"
          placeholder="请选择学校"
        ></uni-data-select>
      </uni-forms-item>

      <uni-forms-item label="用户名" name="username" required>
        <uni-easyinput
          v-model="D.currentModel.username"
          placeholder="请输入用户名"
        ></uni-easyinput>
      </uni-forms-item>

      <uni-forms-item label="姓名" name="realname" required>
        <uni-easyinput
          v-model="D.currentModel.realname"
          placeholder="请输入真实姓名"
        ></uni-easyinput>
      </uni-forms-item>

      <uni-forms-item label="密码" name="password" required>
        <uni-easyinput
          v-model="D.currentModel.password"
          placeholder="请输入密码"
          type="password"
        ></uni-easyinput>
      </uni-forms-item>

      <uni-forms-item
        label="确认密码"
        name="confirmPassword"
        required
      >
        <uni-easyinput
          v-model="D.currentModel.confirmPassword"
          placeholder="请再次输入密码"
          type="password"
        ></uni-easyinput>
      </uni-forms-item>

      <uni-forms-item label="工号" name="num" required>
        <uni-easyinput
          v-model="D.currentModel.num"
          placeholder="请输入工号"
        ></uni-easyinput>
      </uni-forms-item>

      <uni-forms-item label="邮箱" name="email" required>
        <uni-easyinput
          v-model="D.currentModel.email"
          placeholder="请输入邮箱"
        ></uni-easyinput>
      </uni-forms-item>

      <uni-forms-item label="电话" name="phone" required>
        <uni-easyinput
          v-model="D.currentModel.phone"
          placeholder="请输入电话"
        ></uni-easyinput>
      </uni-forms-item>

      <uni-forms-item label="职位" name="title" required>
        <uni-easyinput
          v-model="D.currentModel.title"
          placeholder="请输入职位"
        ></uni-easyinput>
      </uni-forms-item>
    </uni-forms>
    <button type="primary" @click="doSubmit">注册</button>
  </view>
</template>

<script setup>
import { ref } from "vue";
import D from "@/js/user/admin-register.js";

const formRef = ref(null);

const doSubmit = () => {
  // 将表单引用传递给handleSubmit方法
  D.handleSubmit(formRef.value);
};
</script>

<style type="text/css">
.container {
  display: flex !important;
  flex-direction: column;
}

.content {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.title {
  font-size: 36rpx;
  color: #8f8f94;
}

.vcbox {
  display: flex !important;
  flex-direction: column;
  margin: 15px;
  padding-left: 10px;
  padding-right: 10px;
}
</style>